# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RatePlan do
  @moduledoc """
  Rate plan details.

  ## Attributes

  *   `apiproduct` (*type:* `String.t`, *default:* `nil`) - Name of the API product that the rate plan is associated with.
  *   `billingPeriod` (*type:* `String.t`, *default:* `nil`) - Frequency at which the customer will be billed.
  *   `consumptionPricingRates` (*type:* `list(GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RateRange.t)`, *default:* `nil`) - API call volume ranges and the fees charged when the total number of API calls is within a given range. The method used to calculate the final fee depends on the selected pricing model. For example, if the pricing model is `STAIRSTEP` and the ranges are defined as follows: ``` { "start": 1, "end": 100, "fee": 75 }, { "start": 101, "end": 200, "fee": 100 }, } ``` Then the following fees would be charged based on the total number of API calls (assuming the currency selected is `USD`): * 1 call costs $75 * 50 calls cost $75 * 150 calls cost $100 The number of API calls cannot exceed 200.
  *   `consumptionPricingType` (*type:* `String.t`, *default:* `nil`) - Pricing model used for consumption-based charges.
  *   `createdAt` (*type:* `String.t`, *default:* `nil`) - Output only. Time that the rate plan was created in milliseconds since epoch.
  *   `currencyCode` (*type:* `String.t`, *default:* `nil`) - Currency to be used for billing. Consists of a three-letter code as defined by the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) standard.
  *   `description` (*type:* `String.t`, *default:* `nil`) - Description of the rate plan.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - Display name of the rate plan.
  *   `endTime` (*type:* `String.t`, *default:* `nil`) - Time when the rate plan will expire in milliseconds since epoch. Set to 0 or `null` to indicate that the rate plan should never expire.
  *   `fixedFeeFrequency` (*type:* `integer()`, *default:* `nil`) - Frequency at which the fixed fee is charged.
  *   `fixedRecurringFee` (*type:* `GoogleApi.Apigee.V1.Model.GoogleTypeMoney.t`, *default:* `nil`) - Fixed amount that is charged at a defined interval and billed in advance of use of the API product. The fee will be prorated for the first billing period.
  *   `lastModifiedAt` (*type:* `String.t`, *default:* `nil`) - Output only. Time the rate plan was last modified in milliseconds since epoch.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Output only. Name of the rate plan.
  *   `paymentFundingModel` (*type:* `String.t`, *default:* `nil`) - DEPRECATED: This field is no longer supported and will eventually be removed when Apigee Hybrid 1.5/1.6 is no longer supported. Instead, use the `billingType` field inside `DeveloperMonetizationConfig` resource. Flag that specifies the billing account type, prepaid or postpaid.
  *   `revenueShareRates` (*type:* `list(GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RevenueShareRange.t)`, *default:* `nil`) - Details of the revenue sharing model.
  *   `revenueShareType` (*type:* `String.t`, *default:* `nil`) - Method used to calculate the revenue that is shared with developers.
  *   `setupFee` (*type:* `GoogleApi.Apigee.V1.Model.GoogleTypeMoney.t`, *default:* `nil`) - Initial, one-time fee paid when purchasing the API product.
  *   `startTime` (*type:* `String.t`, *default:* `nil`) - Time when the rate plan becomes active in milliseconds since epoch.
  *   `state` (*type:* `String.t`, *default:* `nil`) - Current state of the rate plan (draft or published).
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :apiproduct => String.t() | nil,
          :billingPeriod => String.t() | nil,
          :consumptionPricingRates =>
            list(GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RateRange.t()) | nil,
          :consumptionPricingType => String.t() | nil,
          :createdAt => String.t() | nil,
          :currencyCode => String.t() | nil,
          :description => String.t() | nil,
          :displayName => String.t() | nil,
          :endTime => String.t() | nil,
          :fixedFeeFrequency => integer() | nil,
          :fixedRecurringFee => GoogleApi.Apigee.V1.Model.GoogleTypeMoney.t() | nil,
          :lastModifiedAt => String.t() | nil,
          :name => String.t() | nil,
          :paymentFundingModel => String.t() | nil,
          :revenueShareRates =>
            list(GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RevenueShareRange.t()) | nil,
          :revenueShareType => String.t() | nil,
          :setupFee => GoogleApi.Apigee.V1.Model.GoogleTypeMoney.t() | nil,
          :startTime => String.t() | nil,
          :state => String.t() | nil
        }

  field(:apiproduct)
  field(:billingPeriod)

  field(:consumptionPricingRates,
    as: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RateRange,
    type: :list
  )

  field(:consumptionPricingType)
  field(:createdAt)
  field(:currencyCode)
  field(:description)
  field(:displayName)
  field(:endTime)
  field(:fixedFeeFrequency)
  field(:fixedRecurringFee, as: GoogleApi.Apigee.V1.Model.GoogleTypeMoney)
  field(:lastModifiedAt)
  field(:name)
  field(:paymentFundingModel)

  field(:revenueShareRates,
    as: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RevenueShareRange,
    type: :list
  )

  field(:revenueShareType)
  field(:setupFee, as: GoogleApi.Apigee.V1.Model.GoogleTypeMoney)
  field(:startTime)
  field(:state)
end

defimpl Poison.Decoder, for: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RatePlan do
  def decode(value, options) do
    GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RatePlan.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1RatePlan do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
